<!--
@author	Yi Bo <etng2004@gmail.com>
@version	$Id: client_list.php 67 2007-09-10 09:22:29Z etng2004 $
@copyrithg	2006-2007 ETE.CN
@license 	PHP Version 3.0 {@link http://www.php.net/license/3_0.txt}
-->
<?php
$this->declareVars();
require_once(dirname(__FILE__) . '/_meta_client.php');
echo $this->render('header.php');

/**
 * 列表相应参数
 */
$checkbox_group = 'Client';
?>
<script type="text/javascript">
<!--
function validateBatchOperateForm(checkboxGroup)
{
	var errors=[];
	if(!checkboxGroup.selected.length)errors.push('请选择至少一个对象！');

	//	var f_status = document.getElementById('field_status');
	//	var v_status = f_status.options[f_status.selectedIndex].value;
	//	if(v_status=="")errors.push('请选择至少一种批量操作！');

	if(errors.length)
	{
		alert("请纠正以下错误后再继续操作：\n\n"+errors.join("\n"));
		return false;
	}
	return true;
}
//-->
</script>
<div id="Whatever">
	<ul class="CategoryListTableLevel1">
	<?php
	foreach ($this->trade_types as $trade_type=>$text):
	?>
		<li><a href="<?php echo $this->base_url; ?>/list/trade/<?php echo $trade_type; ?>"><?php echo $text; ?></a><i>(<?php echo $this->statics[$trade_type]; ?>)</i></li>
	<?php
	endforeach;
	?>
	<li><a href="<?php echo $this->base_url; ?>/list/trade/0">所有</a><i>(<?php echo $this->statics['ALL']; ?>))</i></li>
	</ul>
	<div class="HackBox"></div>
</div>



<table cellpadding="0" cellspacing="0" width="100%">
  <tr>
    <td><!--表头区域，可以用来做搜索等信息的展示-->
    </td>
  </tr>
  <tr>
    <td align="center" valign="top" width="100%">
    <form method="post" action="<?php echo $this->base_url; ?>/batchOperate/" id="frmBatchOperate" name="frmBatchOperate" onsubmit="return validateBatchOperateForm(<?php echo $checkbox_group;?>ChkGroup);">
    <table cellspacing="0" cellpadding="0" id="<?php echo strtolower($checkbox_group);?>_list" class="tblborder" width="100%">
        <tr class="tblhead">
          <td> - </td>
          <td> 编号 </td>
          <td> 公司 </td>
          <td> 行业 </td>
          <td> Alexa </td>
          <td> 联系人 </td>
          <td> QQ </td>
           <td> 等级 </td>
          <td> 加入时间 </td>
          <td> 最后联系 </td>
          <td> 备注 </td>
          <td> 操作 </td>
        </tr>
        <?php
        if(!$this->clients):
	?>
        <tr class="tblbody">
          <td colspan="20"> 无记录 </td>
        </tr>
        <?php
        else:
        foreach ($this->clients as $client):
	?>
        <tr class="tblbody">
          <td><input type="checkbox" name="fields[<?php echo strtolower($checkbox_group);?>_id][]" id="fields_<?php echo strtolower($checkbox_group);?>_<?php echo $client['id']; ?>" value="<?php echo $client['id']; ?>"/>
          </td>
          <td><?php echo $client['id'] ?></td>
          <td><a href="<?php echo $client['website'] ?>" target="_blank"><?php echo $client['company'] ?></a></td>
          <td><?php echo $this->trade_types[$client['trade_type_id']]; ?></td>
          <td><?php echo $client['alexa']; ?></td>
          <td><?php echo $client['contact_name']; ?></td>
          <td><?php echo $client['contact_qq']; ?></td>
          <td><?php echo $LANG['CLIENT_STAGE'][$client['stage']]; ?></td>
          <td><?php echo $client['created_by']; ?>(<?php echo date('Y-m-d', $client['created_at']); ?>)</td>
          <td><?php echo $client['last_contact_by']; ?>(<?php echo date('Y-m-d', $client['last_contact_at']); ?>)</td>
          <td><?php echo truncate( strip_tags($client['memo']), 10); ?></td>
          <td>
          <a href=" <?php echo $this->base_url;?>/view/id/<?php echo $client['id']; ?>">查看</a>
          <a href=" <?php echo $this->base_url;?>/edit/id/<?php echo $client['id']; ?>">编辑</a>
          <a href=" <?php echo $this->base_url;?>/trash/id/<?php echo $client['id']; ?>">删除</a>
            </td>
        </tr>
        <?php
        endforeach;
	?>
        <tr class="tblfoot">
          <td colspan="20">
		<a href="javascript:void(0);" onclick="<?php echo $checkbox_group;?>ChkGroup.all();">全选</a>
		<a href="javascript:void(0);" onclick="<?php echo $checkbox_group;?>ChkGroup.inverse();">反选</a>
		<a href="javascript:void(0);" onclick="<?php echo $checkbox_group;?>ChkGroup.clear();">不选</a>
		对选中的对象：
  <select name="operate[status]" id="field_status">
  <option value="">===审核===</option>
<?php
$lang_status_op = array();
foreach ($lang_status_op as $status => $text) {
	if($this->status==$status)continue;
	echo "<option value=\"{$status}\">{$text}</option>\n";
}
  ?>
  </select><input type="submit" value="设置"  />
          </td>
        </tr>
        <tr class="tblfoot">
          <td colspan="20" align="right"><?php
          echo $this->pagination($this->pager['total'], $this->pager['curpage'], $this->pager['perpage'], $this->pager['url'] );
?>
          </td>
        </tr>
        <?php
        endif;
	?>
      </table>
      </form>
      <script type="text/javascript">
      <!--
      var <?php echo $checkbox_group;?>ChkGroup = new EtCheckboxes('<?php echo strtolower($checkbox_group);?>_list','fields_<?php echo strtolower($checkbox_group);?>_',[]);
      //-->
</script>
      </td>
  </tr>
  <tr>
    <td>others</td>
  </tr>
</table>
<?php
?>
<?php echo $this->render('footer.php');?>